package com.ruoyi.mespro.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mespro.domain.AlldataWarping;
import com.ruoyi.mespro.service.IAlldataWarpingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 整经机实时数据Controller
 * 
 * @author Jun Xiang
 * @date 2022-06-07
 */
@RestController
@RequestMapping("/realtime/warp")
public class AlldataWarpingController extends BaseController
{
    @Autowired
    private IAlldataWarpingService alldataWarpingService;

    /**
     * 查询整经机实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('realtime:warp:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlldataWarping alldataWarping)
    {
        startPage();
        List<AlldataWarping> list = alldataWarpingService.selectAlldataWarpingList(alldataWarping);
        return getDataTable(list);
    }

    /**
     * 导出整经机实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('realtime:warp:export')")
    @Log(title = "整经机实时数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AlldataWarping alldataWarping)
    {
        List<AlldataWarping> list = alldataWarpingService.selectAlldataWarpingList(alldataWarping);
        ExcelUtil<AlldataWarping> util = new ExcelUtil<AlldataWarping>(AlldataWarping.class);
        return util.exportExcel(list, "整经机实时数据数据");
    }

    /**
     * 获取整经机实时数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('realtime:warp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(alldataWarpingService.selectAlldataWarpingById(id));
    }

    /**
     * 新增整经机实时数据
     */
    @PreAuthorize("@ss.hasPermi('realtime:warp:add')")
    @Log(title = "整经机实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlldataWarping alldataWarping)
    {
        return toAjax(alldataWarpingService.insertAlldataWarping(alldataWarping));
    }

    /**
     * 修改整经机实时数据
     */
    @PreAuthorize("@ss.hasPermi('realtime:warp:edit')")
    @Log(title = "整经机实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlldataWarping alldataWarping)
    {
        return toAjax(alldataWarpingService.updateAlldataWarping(alldataWarping));
    }

    /**
     * 删除整经机实时数据
     */
    @PreAuthorize("@ss.hasPermi('realtime:warp:remove')")
    @Log(title = "整经机实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(alldataWarpingService.deleteAlldataWarpingByIds(ids));
    }
}
